from django.db import models

# Create your models here.

class PersonSf(models.Model):
    person_sf = models.CharField(max_length = 20,null = True,blank = True)

    def __str__(self):
        return self.person_sf
    
class PersonID(models.Model):
    sf = models.ForeignKey(PersonSf,on_delete = models.CASCADE,null = True)
    person_name = models.CharField(max_length = 50)
    person_id = models.CharField('身份证号码',max_length = 18,unique = True)
    person_pswd = models.CharField(max_length = 16,null = True)

    def __str__(self):
        return self.person_name

class SavePaper(models.Model):
    person_id = models.ForeignKey(PersonID,on_delete = models.CASCADE,null = True)
    paper_name = models.CharField(max_length = 50,null = True,unique = True)
    paper_info = models.CharField(max_length = 2000,null = True)
    pub_date = models.DateTimeField(auto_now_add = True)

    def __str__(self):
        return self.paper_name

class DefaultPaper(models.Model):
    save_paper = models.ForeignKey(SavePaper,on_delete = models.CASCADE,null = True)
    default_paper = models.CharField(max_length = 50,null = True)
    def __str__(self):
        return self.default_paper

class Batch(models.Model):
    paper_name = models.ForeignKey(SavePaper,on_delete = models.CASCADE,null = True)
    batch_name = models.ForeignKey(PersonID,on_delete = models.CASCADE,null = True)
    batch_detail = models.CharField(max_length = 1000)
    batch_score = models.CharField(max_length = 100)

    def __str__(self):
        return self.paper_name.paper_name+'--分数'+self.batch_score+'--批卷人'+self.batch_name.person_name

